package com.mzy.tomcat;

import com.mzy.tomcat.handler.MzyRequestHandler;
import com.mzy.tomcat.servlet.MzyHttpServlet;
import com.mzy.tomcat.utils.ScanAnnotation;

import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ConcurrentHashMap;

/**
 * V3 版本基于注解的Servlet实现
 */
public class MzyTomcatV3 {
    public static final ConcurrentHashMap<String, String> servletUrlMapping = new ConcurrentHashMap<>();
    public static final ConcurrentHashMap<String, MzyHttpServlet> servletClassMapping = new ConcurrentHashMap<>();
    public static void main(String[] args) throws Exception {
        ScanAnnotation.initAnnotation();

        ServerSocket serverSocket = new ServerSocket(8080);
        System.out.println("============8080端口监听中============");
        while (!serverSocket.isClosed()) {
            Socket socket = serverSocket.accept();
            new Thread(new MzyRequestHandler(socket)).start();
        }
        serverSocket.close();
    }
}
